#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>

int main()
{
	char buffer[20];
	int a = 12345;
	int b = 678;

	sprintf(buffer, "%d", a);
	sprintf(buffer + strlen(buffer), "%d", b);
	sprintf(buffer + strlen(buffer), "%s", "->");


	return 0;
}

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
char** summaryRanges(int* nums, int numsSize, int* returnSize) {
    char** ret = (char**)malloc(sizeof(char*) * numsSize);
    *returnSize = 0;

    int left = 0;
    int right = 0;

    while (left < numsSize)
    {
        if (right >= numsSize - 1 || (long long)nums[right + 1] - (long long)nums[right] != 1)
        {
            ret[*returnSize] = (char*)malloc(sizeof(char) * 25);

            sprintf(ret[*returnSize], "%d", nums[left]);

            if (nums[left] < nums[right])
            {
                sprintf(ret[*returnSize] + strlen(ret[*returnSize]), "%s", "->");
                sprintf(ret[*returnSize] + strlen(ret[*returnSize]), "%d", nums[right]);

                right++;
                left = right;
            }
            else
            {
                left++;
                right++;
            }


            (*returnSize)++;
        }
        else
            right++;
    }

    return ret;
}